home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / sep91.zip / 9N09084A < prev    next >
Text File  |  1991-07-10  |  3KB  |  84 lines

  1. /*****************************************************
  2.  * Listing 4  hc_error.c
  3.  *
  4.  * Error handler for HOSTCOM
  5.  *
  6.  ****************************************************/
  7.  
  8. #include <conio.h>
  9. #include "hc.h"
  10.  
  11. static char *hostcom_err[] = {
  12.  "",    /* hostcom_err[0] not used */
  13.  "Not connected to session",
  14.  "Invalid PSID",
  15.  "Connection to PS failed",
  16.  "Host busy, not all keystrokes sent",
  17.  "Input inhibited or rejected, all keys not sent",
  18.  "System error (a host problem)",
  19.  "Timeout error while waiting. Try IGNORE first"
  20.  " to give host more time to respond",
  21.  "input_to_host(): invalid prm passed to send_key()",
  22.  "find_msg(): invalid param passed to send_key()",
  23.  "Keyboard locked",
  24.  "keys_to_host(): invalid param passed to send_key()",
  25.  "Resource unavailable; PS in use",
  26.  "Bad PSID or data string in dspy_cursor()"
  27. };
  28.  
  29. int process_error(int host_err)
  30. {
  31.         int k, y = 1;
  32.  
  33.         write_string(1, y++,
  34.                 hostcom_err[host_err], stat_attr);
  35.         write_string(1, y++,
  36.                 "Select recovery option:", stat_attr);
  37.         write_string(1, y++,
  38.                 " 1. 3270 Clear", stat_attr);
  39.         write_string(1, y++,
  40.                 " 2. 3270 Reset", stat_attr);
  41.         write_string(1, y++,
  42.                 " 3. Ignore error", stat_attr);
  43.         write_string(1, y++,
  44.                 " 4. Exit unconditionally",stat_attr);
  45.  
  46.         do {
  47.                 k = get_key();
  48.         } while (k < '1' || k > '4');
  49.  
  50.         /* Process recovery option.  If clear or reset
  51.          * fails then exit program. send_key() is used
  52.          * instead of input_to_host() to avoid a call
  53.          * to host_wait(), which would result in an
  54.          * immediate failure if the host needs a clear
  55.          * or reset is called for.
  56.          */
  57.  
  58.         switch (k) {
  59.         case '1':               /* clear */
  60.                 /* If the clear key flag is not set,
  61.                  * send enter key then clear
  62.                  */
  63.                 if (clear_flag == 0) {
  64.                         if (send_key("@E") != 0)
  65.                         return(1);
  66.                 }
  67.                 clear_flag = 0;  /* reset clear flag */
  68.                 if (send_key("@C") != 0)
  69.                         return(1);
  70.                 else
  71.                         return(0);
  72.  
  73.         case '2':               /* reset */
  74.                 if (send_key("@R") != 0)
  75.                         return(1);
  76.                 else
  77.                         return(0);
  78.  
  79.         case '3': return(0); /* ignore */
  80.  
  81.         case '4': return(1); /* exit */
  82.         }
  83. }
  84.